/***************************************************************************

-------------------
    begin                : 
    copyright            : kuzkok
    email                : kuzkok at gmail.com

***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*   
*   Данная программа является свободным программным обеспечением;         *
*   Вы можете распространять ее и/или модифицировать в соответствии с     *
*   GNU General Public License опубликованной Фондом свободного           *
*   программного обеспечения; используемая версия лицензии - 2 или        *
*   (по вашему выбору) любая более поздняя                                *
***************************************************************************/

#include "altrefmeasure.h"

AltRefMeasure::AltRefMeasure() :
        CenterlineObject("altrefmeasure")
{
}

AltRefMeasure::AltRefMeasure(QUuid theEventID) :
        CenterlineObject(theEventID, "alrtefmeasure")
{
    if(mObjectState)
    {
        mBeginStationSeriesEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("beginstationserieseventid")).toString());
        mEndStationSeriesEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("endstationserieseventid")).toString());
        mClassEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("classeventid")).toString());
        mBeginStation = mSelectQuery->value(mSelectQuery->record().indexOf("beginstation")).toDouble();
        mEndStation = mSelectQuery->value(mSelectQuery->record().indexOf("endstation")).toDouble();
        mTotalLength = mSelectQuery->value(mSelectQuery->record().indexOf("totallength")).toDouble();
        mSubTypeCD = mSelectQuery->value(mSelectQuery->record().indexOf("subtypecd")).toInt();
    }

}


void AltRefMeasure::buildInsertStatement()
{
    CenterlineObject::buildInsertStatement();
    mInsertStatementFields += ", beginstationserieseventid"
                             ", endstationserieseventid"
                             ", classeventid"
                             ", subtypecd"
                             ", beginstation"
                             ", endstation"
                             ", totallength";
    mInsertStatementValues += ", :beginstationserieseventid"
                             ", :endstationserieseventid"
                             ", :classeventid"
                             ", :subtypecd"
                             ", :beginstation"
                             ", :endstation"
                             ", :totallength";
}

void AltRefMeasure::buildUpdateStatement()
{
    CenterlineObject::buildUpdateStatement();
    mUpdateStatement += ",beginstationserieseventid = :beginstationserieseventid"
                       ",endstationserieseventid = :endstationserieseventid"
                       ",classeventid = :classeventid"
                       ",subtypecd = :subtypecd"
                       ",beginstation = :beginstation"
                       ",endstation = :endstation"
                       ",totallength = :totallength";
}


void AltRefMeasure::bindQueryValues(QSqlQuery &query)
{
    CenterlineObject::bindQueryValues(query);
    query.bindValue(":beginstationserieseventid", UuidToVariant(mBeginStationSeriesEventID));
    query.bindValue(":endstationserieseventid", UuidToVariant(mEndStationSeriesEventID));
    query.bindValue(":classeventid", UuidToVariant(mClassEventID));
    query.bindValue(":subtypecd", mSubTypeCD);
    query.bindValue(":beginstation", mBeginStation);
    query.bindValue(":endstation", mEndStation);
    query.bindValue(":totallength", mTotalLength);
}
